const labelService = require("../service/label.service");

class LabelController {
  // 创建
  async create(ctx, next) {
    try {
      const { name } = ctx.request.body;
      const result = await labelService.create(name);
      ctx.body = {
        data: result,
        code: 200,
        message: "标签创建成功",
      };
    } catch (error) {
      console.log(error, "888");
    }
  }

  async list(ctx, next) {
    try {
      const { limit = 10, offset = 0 } = ctx.query;
      const result = await labelService.getLabels(limit, offset);
      ctx.body = result;
    } catch (error) {
      console.log(error, "labelcontroller");
    }
  }
}

module.exports = new LabelController();
